Background Generator

Charlie Veniot5th March 2022 at 6:54pm
' BASIC Anywhere Machine code sample by Charlie Veniot
' Project web site: https://basicanywheremachine.neocities.org/
'
screen 21 : s_w = 1280 : s_h = 1024
dim c_inc_r, c_inc_g, c_inc_b, c_inc_r_tot, c_inc_g_tot, c_inc_b_tot, c_now as double 
'
c_out_r = 255 : c_out_g = 0 : c_out_b = 255 : c_mid_r = 255 : c_mid_g = 255 : c_mid_b = 0
'
def fnc_inc(c1, c2) = ( c1 - c2 ) / ( s_h / 2 )
c_inc_r = fnc_inc( c_out_r, c_mid_r )
c_inc_g = fnc_inc( c_out_g, c_mid_g )
c_inc_b = fnc_inc( c_out_b, c_mid_b )
'
c_inc_r_tot = 0 : c_inc_g_tot = 0 : c_inc_b_tot = 0
def fnc_now() = ( c_out_r + int(c_inc_r_tot) ) * 256^2 + ( c_out_g + int(c_inc_g_tot) ) * 256 + ( c_out_b + int(c_inc_b_tot) )
c_now = fnc_now()
'
for row = 1 to (s_h - 2)
	sleep 0.00625
	if row > (s_h / 2 - 1) AND row < (s_h / 2 + 1)  then c_now = &hffffff
	line (1, row) - (s_w - 2,row), c_now
	if row <= s_h / 2 then
		c_inc_r_tot -= c_inc_r : c_inc_g_tot -= c_inc_g : c_inc_b_tot -= c_inc_b
	else
		c_inc_r_tot += c_inc_r : c_inc_g_tot += c_inc_g : c_inc_b_tot += c_inc_b
	end if
	c_now = fnc_now()
next row